package com.zkj.context;

/**
 * @author: zhangKaiJun
 * @createTime：2024/8/26
 * @description：
 *  Thre
 */
public class BaseContext {

    // 定义一个ThreadLocal变量，用于存储当前线程的用户ID
    public static ThreadLocal<Long> threadLocal = new ThreadLocal<Long>();

    // 设置当前线程的用户ID
    public static void setCurrentId(Long userId) {
        threadLocal.set(userId);
    }

    // 获取当前线程的用户ID
    public static Long getCurrentId() {
        return threadLocal.get();
    }

    // 清除当前线程的用户ID
    public static void removeCurrentId() {
        threadLocal.remove();
    }
}
